package geppetto.phraseHMM.phraseExtraction.sentencePair;


import geppetto.cat.alignments.Alignment;

import java.util.ArrayList;



public class SizeBasedPhrasePairCandidateExtractor implements PhrasePairCandidateExtractor{
	protected int maxSourceSize;
	protected int maxTargetSize;
	
	public SizeBasedPhrasePairCandidateExtractor(int maxSourceSize,
			int maxTargetSize) {
		super();
		this.maxSourceSize = maxSourceSize;
		this.maxTargetSize = maxTargetSize;
	}

	public PhrasePairCandidate[] extractSentencePairs(int[] foreingSentence,
			int[] sourceSentence, int sentenceNumber) {
		int tSize = foreingSentence.length;
		int sSize = sourceSentence.length;
		ArrayList<PhrasePairCandidate> sentencePairs = new ArrayList<PhrasePairCandidate>();
		for (int targetStartPos = 0; targetStartPos < tSize; targetStartPos++){
			for(int targetEndPos = targetStartPos; targetEndPos < targetStartPos + maxTargetSize && targetEndPos < tSize; targetEndPos++){
				for(int sourceStartPos = 0; sourceStartPos < sSize; sourceStartPos++){
					for(int sourceEndPos = sourceStartPos; sourceEndPos < sourceStartPos + maxSourceSize && sourceEndPos < sSize; sourceEndPos++){
						sentencePairs.add(new PhrasePairCandidate(foreingSentence, sourceSentence, sourceStartPos, targetStartPos, sourceEndPos, targetEndPos));
					}
				}
			}
		}		
		return sentencePairs.toArray(new PhrasePairCandidate[0]);
	}
}
